<?php
/**
 * 问卷管理模块
 * @author ChunYang.Jiang<chunyang@staff.sina.com.cn>
 * @version $Id$
 * @copyright sina
 */
class SurveyModule extends ModuleBase
{
	const STATUS_CLOSE = 0; //关闭
	const STATUS_EXPIRED = 3; //过期
	const STATUS_NORMAL = 1; //正常
	const STATUS_UNSTART = 2; //未开始
	
	public static function add($row)
	{
		return parent::queryInsert($row, 'survey');
	}
	
	public static function getSurvey($where, $start, $limit, &$total)
	{
		$res = parent::querySelectSingle(array('count(0) as num'), $where, 'survey');
		if ($res) {
			$total = intval($res['num']);
		}
		return parent::querySelect(array('*'), $where, 'survey', 'id desc', $start, $limit);
	}
	
	public static function getSurveyById($id)
	{
		return parent::querySelectSingle(array('*'), "id={$id}", 'survey');
	}
	
	public static function update($id, $row)
	{
		return parent::queryUpdate($row, "id={$id}", 'survey');
	}
	
	public static function del($id)
	{
		return parent::queryDelete("id={$id}", 'survey');
	}
}